﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LaserHarp
{

    // Beam class stores configuration parameters for each beam in the harp
    class Beam
    {
            public int index;
            public byte note = 64;
            public int status = 0;
            public int X1;
            public int X2;
            public int Y1;
            public int Y2;
            public float slope =1;

            public bool IsNear(BitBucket blob)
            {
                //The IsNear function detects whether a light blob from the camera is close to the location of a harp beam
                return ((blob.avgX > X1 + (slope * (blob.avgY - Y1)) - 10) && (blob.avgX < X1 + (slope * (blob.avgY - Y1)) + 10));
            }

            public byte Aftertouch(BitBucket blob)
            {
                // Aftertouch uses the Y co-ordinate of the light blob to calculate an aftertouch MIDI message
                // that can be used to modulate the synth tone.
                return (byte)((float)(blob.avgY - Y1) / (float)(Y2 - Y1) * 127);
            }
    }
}
